package com.ruoyi.meeting.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.meeting.domain.Yxmeeting;
import com.ruoyi.meeting.service.IYxmeetingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 营销日例会Controller
 * 
 * @author yellow
 * @date 2023-09-14
 */
@RestController
@RequestMapping("/meeting/yxmeeting")
public class YxmeetingController extends BaseController
{
    @Autowired
    private IYxmeetingService yxmeetingService;

    /**
     * 查询营销日例会列表
     */
    @PreAuthorize("@ss.hasPermi('meeting:yxmeeting:list')")
    @GetMapping("/list")
    public TableDataInfo list(Yxmeeting yxmeeting)
    {
        startPage();
        List<Yxmeeting> list = yxmeetingService.selectYxmeetingList(yxmeeting);
        return getDataTable(list);
    }

    /**
     * 导出营销日例会列表
     */
    @PreAuthorize("@ss.hasPermi('meeting:yxmeeting:export')")
    @Log(title = "营销日例会", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Yxmeeting yxmeeting)
    {
        List<Yxmeeting> list = yxmeetingService.selectYxmeetingList(yxmeeting);
        ExcelUtil<Yxmeeting> util = new ExcelUtil<Yxmeeting>(Yxmeeting.class);
        util.exportExcel(response, list, "营销日例会数据");
    }

    /**
     * 获取营销日例会详细信息
     */
    @PreAuthorize("@ss.hasPermi('meeting:yxmeeting:query')")
    @GetMapping(value = "/{hId}")
    public AjaxResult getInfo(@PathVariable("hId") Long hId)
    {
        return AjaxResult.success(yxmeetingService.selectYxmeetingByHId(hId));
    }

    /**
     * 新增营销日例会
     */
    @PreAuthorize("@ss.hasPermi('meeting:yxmeeting:add')")
    @Log(title = "营销日例会", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Yxmeeting yxmeeting)
    {
        return toAjax(yxmeetingService.insertYxmeeting(yxmeeting));
    }

    /**
     * 修改营销日例会
     */
    @PreAuthorize("@ss.hasPermi('meeting:yxmeeting:edit')")
    @Log(title = "营销日例会", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Yxmeeting yxmeeting)
    {
        return toAjax(yxmeetingService.updateYxmeeting(yxmeeting));
    }

    /**
     * 删除营销日例会
     */
    @PreAuthorize("@ss.hasPermi('meeting:yxmeeting:remove')")
    @Log(title = "营销日例会", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hIds}")
    public AjaxResult remove(@PathVariable Long[] hIds)
    {
        return toAjax(yxmeetingService.deleteYxmeetingByHIds(hIds));
    }
}
